package com.ruoyi.web.controller.product;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EaProductGenuine;
import com.ruoyi.system.service.IEaProductGenuineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 集采道地药材清单Controller
 * 
 * @author ruoyi
 * @date 2025-01-22
 */
@RestController
@RequestMapping("/system/genuine")
public class EaProductGenuineController extends BaseController
{
    @Autowired
    private IEaProductGenuineService eaProductGenuineService;

    /**
     * 查询集采道地药材清单列表
     */
    @PreAuthorize("@ss.hasPermi('system:genuine:list')")
    @GetMapping("/list")
    public TableDataInfo list(EaProductGenuine eaProductGenuine)
    {
        startPage();
        List<EaProductGenuine> list = eaProductGenuineService.selectEaProductGenuineList(eaProductGenuine);
        return getDataTable(list);
    }

    /**
     * 导出集采道地药材清单列表
     */
    @PreAuthorize("@ss.hasPermi('system:genuine:export')")
    @Log(title = "集采道地药材清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EaProductGenuine eaProductGenuine)
    {
        List<EaProductGenuine> list = eaProductGenuineService.selectEaProductGenuineList(eaProductGenuine);
        ExcelUtil<EaProductGenuine> util = new ExcelUtil<EaProductGenuine>(EaProductGenuine.class);
        util.exportExcel(response, list, "集采道地药材清单数据");
    }

    /**
     * 获取集采道地药材清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:genuine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(eaProductGenuineService.selectEaProductGenuineById(id));
    }

    /**
     * 新增集采道地药材清单
     */
    @PreAuthorize("@ss.hasPermi('system:genuine:add')")
    @Log(title = "集采道地药材清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EaProductGenuine eaProductGenuine)
    {
        return toAjax(eaProductGenuineService.insertEaProductGenuine(eaProductGenuine));
    }

    /**
     * 修改集采道地药材清单
     */
    @PreAuthorize("@ss.hasPermi('system:genuine:edit')")
    @Log(title = "集采道地药材清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EaProductGenuine eaProductGenuine)
    {
        return toAjax(eaProductGenuineService.updateEaProductGenuine(eaProductGenuine));
    }

    /**
     * 删除集采道地药材清单
     */
    @PreAuthorize("@ss.hasPermi('system:genuine:remove')")
    @Log(title = "集采道地药材清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(eaProductGenuineService.deleteEaProductGenuineByIds(ids));
    }
}
